package cn.fl.system.service.impl;

import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.system.service.ISysFlowManageService;
import cn.fl.system.transform.SysFlowManageVOTransform;
import cn.fl.system.vo.SysFlowManageVO;
import fl.flow.facade.flow.api.IFlowApiService;
import fl.flow.facade.flow.condition.SysFlowManageQueryCondition;
import fl.flow.facade.flow.dto.SysFlowManageDTO;

/**
 * @Description: 流程配置管理 客户端服务层接口实现
 */
@Service
public class SysFlowManageServiceImpl implements ISysFlowManageService {

	/**
	 * 日志
	 */
	@SuppressWarnings("unused")
	private static final Logger logger = LoggerFactory.getLogger(SysFlowManageServiceImpl.class);
	
	/**
	 * 流程 API 暴露服务
	 */
	@Autowired
	private IFlowApiService flowApiService;

	@Override
	public SysFlowManageVO selectById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id))return null;
		//TODO 业务逻辑
		SysFlowManageDTO dto = null;//this.自定义ApiService.selectById(id);
		return SysFlowManageVOTransform.toVO(dto);
	}

	@Override
	public Long add(SysFlowManageVO entity) throws BaseException{
		if(null == entity)return null;
		//return this.sysFlowManageApiService.add(SysFlowManageVOTransform.toDTO(entity));
		//TODO 业务逻辑
		return null;
	}

	@Override
	public boolean removeById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id))return false;
		//return this.sysFlowManageApiService.removeById(id);
		//TODO 业务逻辑
		return false;
	}

	@Override
	public boolean modify(SysFlowManageVO entity) throws BaseException{
		if(null == entity)return false;
		//return this.sysFlowManageApiService.modify(SysFlowManageVOTransform.toDTO(entity));
		//TODO 业务逻辑
		return false;
	}

	@Override
	public Pager searchListPage(Pager page) throws BaseException{
		if(null == page)page = new Pager();
		if(null == page.getCondition())return page;
		SysFlowManageQueryCondition qc = (SysFlowManageQueryCondition)page.getCondition();
		if(StringUtils.isEmpty(qc.getSysCd())) return page;//系统代码必须存在
		return this.flowApiService.searchFlowManageListPage(page);
	}

	@Override
	public boolean modifyFlowIsValidBy(Long id, Integer isValid) throws BaseException {
		if(null == id || null == isValid){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "修改主键或是否有效值参数不完整!");
		}
		return this.flowApiService.modifyFlowManageIsValidBy(id, isValid, CurrentThreadContext.getCurrentUserId(), new Date());
	}

	@Override
	public boolean modifyProcNo(SysFlowManageQueryCondition con) throws BaseException {
		return this.flowApiService.modifyProcNo(con);
	}
}
